package com.lfd.service.impl;

import java.util.List;


import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lfd.mapper.IOrderMapper;
import com.lfd.mapper.IOrderProductMapper;
import com.lfd.entity.Order;
import com.lfd.service.IOrderService;
import com.lfd.util.UserUtil;
import com.lfd.vo.OrderVo;
import com.lfd.vo.OrderProductVo;


@Service
public class IOrderServiceImpl implements IOrderService{
	private static final String OrderProductVo = null;
	@Autowired
	private IOrderMapper iOrderMapper;
	@Autowired
	private IOrderProductMapper iOrderProductMapper;

	@Override
	public List<OrderVo> selectList(Order order, Integer page, Integer limit) {
		
		Long id = UserUtil.getId();
		 
		order.setUserid(id);
		 
		List<OrderVo> selectList = iOrderMapper.selectList(id,order,(page - 1) * limit, limit);
		return selectList;
	}

	@Override
	public void fh(List<Long> ids, Long orderstate) {
	iOrderMapper.fh(ids, orderstate);
		
	}

	@Override
	public void add(OrderVo orderVo, List<Long> list) {
		// TODO Auto-generated method stub
     iOrderMapper.add(orderVo);
       Long orderid = orderVo.getOrderid();
       for (Long pid:list) {
    	OrderProductVo orderProduct = new OrderProductVo();
			orderProduct.setOrderid(orderid);
			orderProduct.setPid(pid);
			iOrderProductMapper.add(orderProduct);
			
		
	}
	}

	@Override
	public void updatepay(Long orderId) {
		// TODO Auto-generated method stub
		
	}

}
